<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class menu_mdl extends CI_Model{
	function __construct(){
		parent::__construct();
		$this->load->database();

	}
	function getListMenu(){
		$query=$this->db->query("SELECT * FROM adm_menu");
		if ($query->num_rows()>0){
			$data = array();
			$i=0;
			foreach ($query->result_array() AS $row){
				
				$row["idmenu"];
				$row["text"];
				$row["page_name"];
				$row["parentid"];
				$row["subMenuWidth"];
				$row["classname"];
				$row["functionname"];
				
				$data[$i] = $row;
				$i++;
			}
			return $data;	
		}
	}
	
    public function SaveAdd($data){
		$this->db->insert('adm_menu',$data);
	}
	
	public function SaveEdit($data){
		$this->db->where('idmenu',$this->input->post('idmenu'));
		$this->db->update('adm_menu',$data);
	} 
	
	public function DeleteMenu($idmenu){
	    $this->db->where('idmenu',$idmenu);
		$this->db->delete('adm_menu'); 
	}
	
	function getPageName($idmenu){
		$this->db->select('page_name');
		$this->db->from('adm_menu');
		$this->db->where('idmenu',$idmenu);
		$query=$this->db->get();
	
		$row=$query->result();
		if($query->num_rows == 1){
			return  $row->page_name;
		}
	}
}
?>